#include <string>
class Solution {
  public:
    int getLongestPalindrome(string A) {
        // 中心拓展算法
        if(A.size() == 1) return 1;
        int left, right, _max = 0, n = 0;
        for (int i = 0; i < A.size(); i++) {
            left = i - 1; right = i + 1;
            while(left >= 0 && right < A.size() && A[left] == A[right])
            {
                left--;
                right++;
            }
            
            _max = max(_max, right - left - 1);

            left = i; right = i + 1;
            while(left >= 0 && right < A.size() && A[left] == A[right])
            {
                left--;
                right++;
            }
            _max = max(_max, right - left - 1);
        }

        return _max;
    }
};